package com.chap11;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * <p>
 * <code>ThreadPoolTest</code>
 * </p>
 *
 * @author junbao3
 * TODO
 * @date 2023-04-03 15:22
 * Copyright (C) 2021 IFlyTek. All rights reserved.
 */
public class ThreadPoolTest3 {
    public static void main(String[] args) {
        ThreadPoolExecutor executor =
                new ThreadPoolExecutor(10,200,1000,
                        TimeUnit.SECONDS,new ArrayBlockingQueue<>(200));

        //往线程池提交任务
        executor.execute(new Runnable() {
            @Override
            public void run() {
                System.out.println("...");
                throw  new NullPointerException();
            }
        });

        //两个方法都会关闭线程池
        executor.shutdown();
        executor.shutdownNow();
    }
}
